import 'package:ecy_app_flutter/ecycommon/EcyWebViewPage.dart';
import 'package:ecy_app_flutter/ecycommon/utils/EcyUserUtil.dart';
import 'package:ecy_app_flutter/main.dart';
import 'package:ecy_app_flutter/routes/blind_box/OpenBoxPage.dart';
import 'package:ecy_app_flutter/routes/blind_box/blind_box_enter.dart';
import 'package:ecy_app_flutter/routes/blind_box/blind_box_more_page.dart';
import 'package:ecy_app_flutter/routes/blind_box/blind_box_multi_choose.dart';
import 'package:ecy_app_flutter/routes/blind_box/blind_box_one_choose.dart';
import 'package:ecy_app_flutter/routes/blind_box/blind_box_page.dart';
import 'package:ecy_app_flutter/routes/blind_box/blind_box_choose.dart';
import 'package:ecy_app_flutter/routes/blind_box/blind_box_detail.dart';
import 'package:ecy_app_flutter/routes/blind_box/blind_box_pictorial.dart';
import 'package:ecy_app_flutter/routes/blind_box/blind_box_myexchange.dart';
import 'package:ecy_app_flutter/routes/blind_box/blind_box_myAssets.dart';
import 'package:ecy_app_flutter/routes/blind_box/exchange_market/pages/EcyExchangeRequestspage.dart';
import 'package:ecy_app_flutter/routes/consignment/EcyConsignmentSearchPage.dart';
import 'package:ecy_app_flutter/routes/consignment/detail/EcyConsignChatPage.dart';
import 'package:ecy_app_flutter/routes/consignment/detail/EcyConsignmentDetailPage.dart';
import 'package:ecy_app_flutter/routes/consignment/detail/EcyConsignmentPublishPage.dart';
import 'package:ecy_app_flutter/routes/consignment/detail/EcyMyConsignmentListSearchPage.dart';
import 'package:ecy_app_flutter/routes/consignment/detail/EcyMyConsignmentOrderDetailPage.dart';
import 'package:ecy_app_flutter/routes/common/ChatScreen.dart';
import 'package:ecy_app_flutter/routes/consignment/my/EcyMyBuyListPage.dart';
import 'package:ecy_app_flutter/routes/consignment/my/EcyMyBuyListSearchPage.dart';
import 'package:ecy_app_flutter/routes/consignment/my/EcyMyPublishListPage.dart';
import 'package:ecy_app_flutter/routes/consignment/my/EcyMySellListPage.dart';
import 'package:ecy_app_flutter/routes/consignment/my/EcyMySellListSearchPage.dart';
import 'package:ecy_app_flutter/routes/goods/EcyGoodsSearchPage.dart';
import 'package:ecy_app_flutter/routes/goods/widgets/common/EcyGoodsCategorySelectPage.dart';
import 'package:ecy_app_flutter/routes/goods/widgets/common/EcyGoodsIPSelectPage.dart';
import 'package:ecy_app_flutter/routes/group/EcyGroupMainPage.dart';
import 'package:ecy_app_flutter/routes/group/EcyGroupSearchPage.dart';
import 'package:ecy_app_flutter/routes/group/detail/EcyGroupDetailPage.dart';
import 'package:ecy_app_flutter/routes/group/detail/EcyGroupPublishPage.dart';
import 'package:ecy_app_flutter/routes/login/EcyPrivacyPolicyPage.dart';
import 'package:ecy_app_flutter/routes/login/EcyRegisterAfterInterestSelectionPage.dart';
import 'package:ecy_app_flutter/routes/login/EcyRegisterSettingPage.dart';
import 'package:ecy_app_flutter/routes/login/EcyResetPasswordPage.dart';
import 'package:ecy_app_flutter/routes/login/EcyVerificationCodeLoginPage.dart';
import 'package:ecy_app_flutter/routes/mainTabPage.dart';
import 'package:ecy_app_flutter/routes/my/EcyMyGroupDraftListPage.dart';
import 'package:ecy_app_flutter/routes/my/EcyMyGroupMainPage.dart';
import 'package:ecy_app_flutter/routes/my/EcyMyMessagePage.dart';
import 'package:ecy_app_flutter/routes/my/EcyMyOrderPage.dart';
import 'package:ecy_app_flutter/routes/my/EcyPersonInfoPage.dart';
import 'package:ecy_app_flutter/routes/my/detail/EcyAfterSaleDetailPage.dart';
import 'package:ecy_app_flutter/routes/my/detail/EcyAfterSalePage.dart';
import 'package:ecy_app_flutter/routes/my/aftersales/EcyExchangeDetailPage.dart';
import 'package:ecy_app_flutter/routes/blind_box/exchange_market/EcyExchangeMarketPage.dart';
import 'package:ecy_app_flutter/routes/blind_box/exchange_market/pages/EcyExchangeApplyPage.dart';
import 'package:ecy_app_flutter/routes/blind_box/exchange_market/pages/EcyCardDetailPage.dart';
import 'package:ecy_app_flutter/routes/blind_box/blind_box_success_page.dart';
import 'package:ecy_app_flutter/routes/blind_box/exchange_market/pages/ExchangeRequestListPage.dart';
import 'package:ecy_app_flutter/routes/my/detail/EcyOrderEvaluateListPage.dart';
import 'package:ecy_app_flutter/routes/my/detail/EcyOrderEvaluatePage.dart';
import 'package:ecy_app_flutter/routes/my/detail/after_sales_page.dart';
import 'package:ecy_app_flutter/routes/my/model/messgae/ChatSession.dart';
import 'package:ecy_app_flutter/routes/my/setting/EcyAboutGoodsQiPage.dart';
import 'package:ecy_app_flutter/routes/my/setting/EcyAddressEditPage.dart';
import 'package:ecy_app_flutter/routes/my/setting/EcyAddressPage.dart';
import 'package:ecy_app_flutter/routes/my/setting/EcyLogOffPage.dart';
import 'package:ecy_app_flutter/routes/pay/EcyOrderConfirmPage.dart';
import 'package:flutter/material.dart';
import 'package:ecy_app_flutter/routes/login/EcyLoginPage.dart';
import 'package:ecy_app_flutter/routes/login/EcyMobileLoginPage.dart';
import 'package:ecy_app_flutter/routes/my/EcyContactUsPage.dart';
import 'package:ecy_app_flutter/routes/login/EcyInputCodeLoginPage.dart';
import 'package:ecy_app_flutter/routes/login/EcyLoginHomePage.dart';
import 'package:ecy_app_flutter/routes/login/EcyOtherMobileLoginPage.dart';
import 'package:ecy_app_flutter/routes/login/EcyRegisterLoginPage.dart';
import 'package:ecy_app_flutter/routes/login/EcyPasswordLoginPage.dart';
import 'package:ecy_app_flutter/routes/goodscart/EcyGoodsCartHomePage.dart';
import 'package:ecy_app_flutter/routes/my/detail/EcyOrderInfoPage.dart';
import 'package:ecy_app_flutter/routes/my/setting/EcyMySettingPage.dart';
import 'package:ecy_app_flutter/routes/my/setting/EcyAccountSecurityPage.dart';
import 'package:ecy_app_flutter/routes/blind_box/exchange_market/pages/EcyExchangeSelectTargetPage.dart';
import 'package:ecy_app_flutter/routes/my/EcySystemNoticePage.dart';

class EcyRouter {
  static const homePage = 'app://';
  static const loginPage = 'app://loginPage';
  static const mobileLoginPage = 'app://mobileLoginPage';
  static const goodsPage = 'app://goodsPage';
  static const zhuanzhuanPage = 'app://zhuanzhuanPagePage';
  static const circlePage = 'app://circlePage';
  static const myOrderPage = 'app://myOrderPage';
  static const orderInfoPage = 'app://orderInfoPage';
  static const personInfoPage = 'app://personInfoPage';

  static const inputCodeLoginPage = 'app://inputCodeLoginPage';
  static const loginHomePage = 'app://loginHomePage';
  static const otherMobileLoginPage = 'app://otherMobileLoginPage';
  static const registerLoginPage = 'app://registerLoginPage';
  static const passwordLoginPage = 'app://passwordLoginPage';

  static const ipSelectPage = 'app://ipSelectPage';
  static const categorySelectPage = 'app://categorySelectPage';
  static const goodsCartHomePage = 'app://goodsCartHomePage';

  static const goodsSearchPage = 'app://goodsSearchPage';

  //支付流程
  static const orderConfirm = 'app://orderConfirm';

  static const kTargetUrl = 'kTargetUrl';
  static const kTargetParam = 'kTargetParam';

  static const orderEvaluatePage = 'app://orderEvaluatePage';
  static const mySettingPage = 'app://mySettingPage';
  static const accountSecurityPage = 'app://accountSecurityPage';
  static const addressPage = 'app://addressPage';
  static const addressEditPage = 'app://addressEditPage';
  static const afterSaleExchangePage = 'app://afterSaleExchangePage';
  static const exchangeMarketPage = 'app://exchangeMarketPage';
  static const exchangeApplyPage = 'app://exchangeApplyPage';
  static const exchangeRequestsPage = 'app://exchangeRequestsPage';
  static const cardDetailPage = 'app://cardDetailPage';
  static const blindBoxChoose = 'app://blindBoxChoose';
  static const blindBoxOneChoose = 'app://blindBoxOneChoose';
  static const blindBoxMultiChoose = 'app://blindBoxMultiChoose';
  static const blindBoxDetail = 'app://blindBoxDetail';
  static const blindBoxPictorial = 'app://blindBoxPictorial';
  static const blindBoxMyexchange = 'app://blindBoxMyexchange';
  static const blindBoxMyAssets = 'app://blindBoxMyAssets';
  static const blindBoxSuccessPage = 'app://blindBoxSuccessPage';
  static const exchangeRequestListPage = 'app://exchangeRequestListPage';
  static const afterSalePage = 'app://afterSalePage';
  static const afterSaleDetailPage = 'app://afterSaleDetailPage';
  static const consignmentSearchPage = 'app://consignmentSearchPage';
  static const consignmentPublishPage = 'app://consignmentPublishPage';
  static const consignmentDetailPage = 'app://consignmentDetailPage';
  static const myConsignmentPublishListPage =
      'app://myConsignmentPublishListPage';
  static const myConsignmentListSearchPage =
      'app://myConsignmentListSearchPage';
  static const myBuyListPage = 'app://myBuyListPage';
  static const myBuyListSearchPage = 'app://myBuyListSearchPage';
  static const mySellListPage = 'app://mySellListPage';
  static const mySellListSearchPage = 'app://mySellListSearchPage';
  static const groupSearchPage = 'app://groupSearchPage';
  static const groupMainPage = 'app://groupMainPage';
  static const groupDetailPage = 'app://groupDetailPage';
  static const groupPublishPage = 'app://groupPublishPage';
  static const myGroupMainPage = 'app://myGroupMainPage';
  static const myGroupDraftListPage = 'app://myGroupDraftListPage';
  static const privacyPolicyPage = 'app://privacyPolicyPage';
  static const resetPasswordPage = 'app://resetPasswordPage';
  static const verificationCodeLoginPage = 'app://verificationCodeLoginPage';
  static const registerAfterInterestSelectionPage =
      'app://registerAfterInterestSelectionPage';
  static const registerSettingPage = 'app://registerSettingPage';
  static const logOffPage = 'app://logOffPage';
  static const consignChatPage = 'app://consignChatPage';
  static const myConsignmentOrderDetailPage =
      'app://myConsignmentOrderDetailPage';
  static const myMessagePage = 'app://myMessagePage';
  static const contactUsPage = 'app://contactUsPage';
  static const aboutGoodsQiPage = 'app://aboutGoodsQiPage';
  static const chatScreen = 'app://chatScreen';
  static const orderEvaluateListPage = 'app://orderEvaluateListPage';
  static const openBoxPage = 'app://openBoxPage';
  static const afterSalesPage = 'app://afterSalesPage';
  static const blindBoxPage = 'app://blindBoxPage';
  static const blindBoxMorePage = 'app://blindBoxMorePage';
  static const blindBoxEnter = 'app://blindBoxEnter';
  static const exchangeSelectTargetPage = 'app://exchangeSelectTargetPage';
  static const systemNoticePage = 'app://systemNoticePage';

  EcyRouter();

  // 路由映射表
  static final _routes = {
    '/': (context, {arguments}) =>
        ContainPage(key: const Key("home"), appLinks: gAppLinks),
    homePage: (context, {arguments}) =>
        ContainPage(key: const Key("home"), appLinks: gAppLinks),
    myOrderPage: (context, {arguments}) => EcyMyOrderPage(arguments ?? 0),
    personInfoPage: (context, {arguments}) =>
        EcyPersonInfoPage(key: const Key("EcyPersonInfoPage")),
    loginPage: (context, {arguments}) =>
        EcyLoginPage(key: const Key("EcyLoginPage")),
    mobileLoginPage: (context, {arguments}) =>
        EcyMobileLoginPage(key: const Key("EcyMobileLoginPage")),
    inputCodeLoginPage: (context, {arguments}) =>
        EcyInputCodeLoginPage(arguments["mobile"]),
    loginHomePage: (context, {arguments}) =>
        EcyLoginHomePage(key: const Key("EcyLoginHomePage")),
    otherMobileLoginPage: (context, {arguments}) =>
        EcyOtherMobileLoginPage(key: const Key("EcyOtherMobileLoginPage")),
    registerLoginPage: (context, {arguments}) => EcyRegisterLoginPage(),
    passwordLoginPage: (context, {arguments}) =>
        EcyPasswordLoginPage(arguments[kTargetUrl], arguments[kTargetParam]),
    ipSelectPage: (context, {arguments}) => EcyGoodsIPSelectPage(),
    categorySelectPage: (context, {arguments}) =>
        EcyGoodsCateogrySelectPage(arguments["model"], arguments["block"]),
    goodsCartHomePage: (context, {arguments}) => EcyGoodsCartHomePage(),
    goodsSearchPage: (context, {arguments}) => EcyGoodsSearchPage(),
    orderConfirm: (context, {arguments}) => EcyOrderConfirmPage(arguments),
    orderInfoPage: (context, {arguments}) => EcyOrderInfoPage(arguments),
    orderEvaluatePage: (context, {arguments}) => EcyOrderEvaluatePage(
        key: const Key("EcyOrderEvaluatePage"), commodity: arguments),
    mySettingPage: (context, {arguments}) =>
        EcyMySettingPage(key: const Key("EcyMySettingPage")),
    accountSecurityPage: (context, {arguments}) =>
        EcyAccountSecurityPage(key: const Key("EcyAccountSecurityPage")),
    addressPage: (context, {arguments}) => EcyAddressPage(
        arguments != null ? arguments["checkFlag"] ?? false : false,
        arguments != null ? arguments["locationId"] : null),
    addressEditPage: (context, {arguments}) => EcyAddressEditPage(
        key: const Key("EcyAddressEditPage"), locationModel: arguments),
    afterSaleExchangePage:(context, {arguments}) =>
        EcyExchangeDetailPage(key: const Key("EcyExchangeDetailPage")),
    exchangeMarketPage:(context, {arguments}) =>
        EcyExchangeMarketPage(),
    exchangeApplyPage:(context, {arguments}) =>
        EcyExchangeApplyPage(),
    exchangeRequestsPage:(context, {arguments}) =>
        EcyExchangeRequestsPage(),
    cardDetailPage:(context, {arguments}) =>
        EcyCardDetailPage(),
    blindBoxChoose:(context, {arguments}) =>
        BlindBoxChoose(commodityPageList: arguments["commodityPageList"]),
    blindBoxOneChoose:(context, {arguments}) =>
        BlindBoxOneChoose(commodityPageList: arguments["commodityPageList"]),
    blindBoxMultiChoose:(context, {arguments}) =>
        BlindBoxMultiChoose(commodityPageList: arguments["commodityPageList"]),
    blindBoxDetail:(context, {arguments}) =>
        BlindBoxDetail(commodityPageList: arguments["commodityPageList"]  ),
    blindBoxPictorial:(context, {arguments}) =>
        BlindBoxPictorialPage(),
    blindBoxMyexchange:(context, {arguments}) =>
        BlindBoxMyexchange(),
    blindBoxMyAssets:(context, {arguments}) =>
        BlindBoxMyAssets(),
    blindBoxSuccessPage: (context, {arguments}) =>
        const BlindBoxSuccessPage(),
    exchangeRequestListPage: (context, {arguments}) =>
        ExchangeRequestListPage(),
    afterSalePage: (context, {arguments}) =>
        EcyAfterSalePage(key: const Key("EcyAfterSalePage")),
    afterSaleDetailPage: (context, {arguments}) =>
        EcyAfterSaleDetailPage(key: const Key("EcyAfterSaleDetailPage")),
    consignmentSearchPage: (context, {arguments}) =>
        EcyConsignmentSearchPage(key: const Key("EcyConsignmentSearchPage")),
    consignmentPublishPage: (context, {arguments}) => EcyConsignmentPublishPage(
        arguments != null ? arguments["productId"] : null,
        key: const Key("EcyConsignmentPublishPage")),
    myConsignmentPublishListPage: (context, {arguments}) =>
        const EcyMyPublishListPage(key: Key("myConsignmentPublishListPage")),
    myConsignmentListSearchPage: (context, {arguments}) =>
        EcyMyConsignmentListSearchPage(
            key: const Key("EcyMyConsignmentListSearchPage")),
    myBuyListPage: (context, {arguments}) =>
        const EcyMyBuyListPage(key: Key("EcyMyBuyListPage")),
    myBuyListSearchPage: (context, {arguments}) =>
        EcyMyBuyListSearchPage(key: const Key("EcyMyBuyListSearchPage")),
    mySellListPage: (context, {arguments}) =>
        const EcyMySellListPage(key: Key("EcyMySellListPage")),
    mySellListSearchPage: (context, {arguments}) =>
        EcyMySellListSearchPage(key: const Key("EcyMySellListSearchPage")),
    myConsignmentOrderDetailPage: (context, {arguments}) =>
        EcyMyConsignmentOrderDetailPage(
            arguments != null ? arguments["orderCode"] : "",
            arguments != null ? arguments["type"] : null),
    contactUsPage: (context, {arguments}) => EcyContactUsPage(),
    groupSearchPage: (context, {arguments}) =>
        EcyGroupSearchPage(key: const Key("EcyGroupSearchPage")),
    groupDetailPage: (context, {arguments}) => EcyGroupDetailPage(
        key: const Key("EcyGroupDetailPage"),
        id: arguments != null ? arguments["id"] : null),
    groupPublishPage: (context, {arguments}) => EcyGroupPublishPage(
        key: const Key("EcyGroupPublishPage"),
        id: arguments != null ? arguments["id"] : null),
    myGroupMainPage: (context, {arguments}) => EcyMyGroupMainPage(),
    myGroupDraftListPage: (context, {arguments}) => EcyMyGroupDraftListPage(),
    groupMainPage: (context, {arguments}) => EcyGroupMainPage(),
    privacyPolicyPage: (context, {arguments}) =>
        EcyPrivacyPolicyPage(arguments["url"], arguments["title"]),
    resetPasswordPage: (context, {arguments}) => EcyResetPasswordPage(),
    verificationCodeLoginPage: (context, {arguments}) =>
        EcyVerificationCodeLoginPage(),
    registerAfterInterestSelectionPage: (context, {arguments}) =>
        EcyRegisterAfterInterestSelectionPage(),
    registerSettingPage: (context, {arguments}) => EcyRegisterSettingPage(),
    logOffPage: (context, {arguments}) =>
        const EcyLogOffPage(key: Key("logOffPage")),
    consignChatPage: (context, {arguments}) => EcyConsignChatPage(
        key: const Key("EcyConsignChatPage"),
        consignProduct: arguments["consignProduct"]),
    myMessagePage: (context, {arguments}) =>
        const EcyMyMessagePage(key: Key("EcyMyMessagePage")),
    aboutGoodsQiPage: (context, {arguments}) =>
        const EcyAboutGoodsQiPage(key: Key("EcyAboutGoodsQiPage")),
    chatScreen: (context, {arguments}) => ChatScreen(
          key: const Key("ChatScreen"),
          chatSession:
              arguments != null ? arguments["ChatSession"] : ChatSession(),
        ),
    orderEvaluateListPage: (context, {arguments}) => EcyOrderEvaluateListPage(
          key: const Key("EcyOrderEvaluateListPage"),
          commodityList: arguments ?? [],
        ),
    openBoxPage: (context, {arguments}) =>
      const OpenBoxPage(key: Key("openBoxPage")),
    afterSalesPage: (context, {arguments}) =>
      const AfterSalesPage(key: Key("afterSalesPage")),
    openBoxPage: (context, {arguments}) => const OpenBoxPage(key: Key("openBoxPage")),
    afterSalesPage: (context, {arguments}) => const AfterSalesPage(key: Key("afterSalesPage")),
    blindBoxPage: (context, {arguments}) => BlindBoxPage(key: const Key("blindBoxPage")),
    blindBoxMorePage: (context, {arguments}) => BlindBoxMorePage(key: const Key("blindBoxMorePage"), ipCode: arguments["ipCode"], ipName: arguments["ipName"]),
    blindBoxEnter: (context, {arguments}) => BlindBoxEnter(key: Key("blindBoxEnter"), commodityName: arguments["commodityName"], ipCode: arguments["ipCode"],initialCommodityId: arguments["initialCommodityId"],ipName: arguments["ipName"]),
    exchangeSelectTargetPage: (context, {arguments}) => EcyExchangeSelectTargetPage(),
    systemNoticePage: (context, {arguments}) => const EcySystemNoticePage(),
  };

  // 命名路由传参设置
  Route<dynamic>? onGenerateRoute(RouteSettings settings) {
    final String? name = settings.name;
    final Function? pageContentBuilder = _routes[name];
    if (pageContentBuilder != null) {
      if (settings.arguments != null) {
        final Route route = MaterialPageRoute(
            builder: (context) =>
                pageContentBuilder(context, arguments: settings.arguments));
        return route;
      } else {
        final Route route = MaterialPageRoute(
            builder: (context) => pageContentBuilder(context));
        return route;
      }
    }
    return MaterialPageRoute(
        builder: (context) => ContainPage(
              key: const Key("home"),
              appLinks: gAppLinks,
            ));
  }

  Widget _getPage(String url, dynamic params) {
    if (url.startsWith('https://') || url.startsWith('http://')) {
      return EcyWebViewPage(url, params["h5Ttile"] ?? "");
    } else {
      switch (url) {
        case loginPage:
          return EcyLoginPage(key: const Key("EcyLoginPage"));
        case mobileLoginPage:
          return EcyMobileLoginPage(key: const Key("EcyMobileLoginPage"));
        case myOrderPage:
          return EcyMyOrderPage(params[kTargetParam] ?? 0);
        case personInfoPage:
          return EcyPersonInfoPage(key: const Key("EcyPersonInfoPage"));
        case inputCodeLoginPage:
          return EcyInputCodeLoginPage(params["mobile"]);
        case loginHomePage:
          return EcyLoginHomePage(key: const Key("EcyLoginHomePage"));
        case otherMobileLoginPage:
          return EcyOtherMobileLoginPage(
              key: const Key("EcyOtherMobileLoginPage"));
        case registerLoginPage:
          return EcyRegisterLoginPage();
        case passwordLoginPage:
          return EcyPasswordLoginPage(
            params[kTargetUrl],
            params[kTargetParam],
          );
        case ipSelectPage:
          return EcyGoodsIPSelectPage();
        case categorySelectPage:
          return EcyGoodsCateogrySelectPage(params["model"], params["block"]);
        case goodsCartHomePage:
          return EcyGoodsCartHomePage();
        case goodsSearchPage:
          return EcyGoodsSearchPage();
        case orderConfirm:
          return EcyOrderConfirmPage(params);
        case orderInfoPage:
          return EcyOrderInfoPage(params);
        case orderEvaluatePage:
          return EcyOrderEvaluatePage(
              key: const Key("EcyOrderEvaluatePage"), commodity: params);
        case mySettingPage:
          return EcyMySettingPage(key: const Key("EcyMySettingPage"));
        case accountSecurityPage:
          return EcyAccountSecurityPage(
              key: const Key("EcyAccountSecurityPage"));
        case addressPage:
          return EcyAddressPage(
              params["checkFlag"] ?? false, params["locationId"]);
        case addressEditPage:
          return EcyAddressEditPage(
              key: const Key("EcyAddressEditPage"), locationModel: params);
        case afterSalePage:
          return EcyAfterSalePage(key: const Key("EcyAfterSalePage"));
        case afterSaleExchangePage:
          return EcyExchangeDetailPage(key: const Key("EcyExchangeDetailPage"));
        case exchangeMarketPage:
          return EcyExchangeMarketPage();
        case exchangeApplyPage:
          return EcyExchangeApplyPage();
        case exchangeRequestsPage:
          return EcyExchangeRequestsPage();
        case cardDetailPage:
          return EcyCardDetailPage();
        case blindBoxChoose:
          return BlindBoxChoose(commodityPageList: params["commodityPageList"]);
        case blindBoxOneChoose:
          return BlindBoxOneChoose(commodityPageList: params["commodityPageList"]);
        case blindBoxMultiChoose:
          return BlindBoxMultiChoose(commodityPageList: params["commodityPageList"]);
        case blindBoxDetail:
          return BlindBoxDetail(commodityPageList: params["commodityPageList"]);
        case blindBoxPictorial:
          return BlindBoxPictorialPage();
        case blindBoxMyexchange:
          return BlindBoxMyexchange();
        case blindBoxMyAssets:
          return BlindBoxMyAssets();
        case blindBoxSuccessPage:
          return const BlindBoxSuccessPage();
        case exchangeRequestListPage:
          return ExchangeRequestListPage();
        case afterSaleDetailPage:
          return EcyAfterSaleDetailPage(
              key: const Key("EcyAfterSaleDetailPage"));
        case consignmentSearchPage:
          return EcyConsignmentSearchPage(
              key: const Key("EcyConsignmentSearchPage"));
        case consignmentPublishPage:
          return EcyConsignmentPublishPage(params["productId"],
              key: const Key("EcyConsignmentPublishPage"));
        case myConsignmentPublishListPage:
          return const EcyMyPublishListPage(
              key: Key("myConsignmentPublishListPage"));
        case myConsignmentListSearchPage:
          return EcyMyConsignmentListSearchPage(
              key: const Key("EcyMyConsignmentListSearchPage"));
        case myBuyListPage:
          return EcyMyBuyListPage(key: const Key("EcyMyBuyListPage"));
        case myBuyListSearchPage:
          return EcyMyBuyListSearchPage(
              key: const Key("EcyMyBuyListSearchPage"));
        case mySellListPage:
          return EcyMySellListPage(key: const Key("EcyMySellListPage"));
        case mySellListSearchPage:
          return EcyMySellListSearchPage(
              key: const Key("EcyMySellListSearchPage"));
        case myConsignmentOrderDetailPage:
          return EcyMyConsignmentOrderDetailPage(
              params["orderCode"], params["type"]);
        case contactUsPage:
          return EcyContactUsPage();
        case groupSearchPage:
          return EcyGroupSearchPage(key: const Key("EcyGroupSearchPage"));
        case groupDetailPage:
          return EcyGroupDetailPage(
              key: const Key("EcyGroupDetailPage"), id: params["id"]);
        case groupPublishPage:
          return EcyGroupPublishPage(
              key: const Key("EcyGroupPublishPage"), id: params["id"]);
        case myGroupMainPage:
          return EcyMyGroupMainPage();
        case myGroupDraftListPage:
          return EcyMyGroupDraftListPage();
        case groupMainPage:
          return EcyGroupMainPage();
        case privacyPolicyPage:
          params = params ?? {};
          return EcyPrivacyPolicyPage(params["url"], params["title"]);
        case resetPasswordPage:
          return EcyResetPasswordPage();
        case verificationCodeLoginPage:
          return EcyVerificationCodeLoginPage();
        case registerAfterInterestSelectionPage:
          return EcyRegisterAfterInterestSelectionPage();
        case registerSettingPage:
          return EcyRegisterSettingPage();
        case logOffPage:
          return const EcyLogOffPage(key: Key("logOffPage"));
        case consignmentDetailPage:
          return EcyConsignmentDetailPage(
              key: const Key("EcyConsignmentPublishPage"),
              productId: params["productId"]);
        case consignChatPage:
          return EcyConsignChatPage(
              key: const Key("EcyConsignChatPage"),
              consignProduct: params["consignProduct"]);
        case myMessagePage:
          return const EcyMyMessagePage(key: Key("EcyMyMessagePage"));
        case aboutGoodsQiPage:
          return const EcyAboutGoodsQiPage(key: Key("EcyAboutGoodsQiPage"));
        case chatScreen:
          return ChatScreen(
            key: const Key("ChatScreen"),
            chatSession: params["chatSession"],
          );
        case orderEvaluateListPage:
          return EcyOrderEvaluateListPage(
            key: const Key("EcyOrderEvaluateListPage"),
            commodityList: params ?? [],
          );
        case openBoxPage:
          return const OpenBoxPage(key: Key("OpenBoxPage"));
        case afterSalesPage:
          return const AfterSalesPage(key: Key("afterSalesPage"));
        case blindBoxPage:
          return BlindBoxPage(key: const Key("blindBoxPage"));
        case blindBoxMorePage:
          return BlindBoxMorePage(key: const Key("blindBoxMorePage"), ipCode: params["ipCode"], ipName: params["ipName"]);
        case blindBoxEnter:
          return BlindBoxEnter(key: Key("blindBoxEnter"), commodityName: params["commodityName"], ipCode: params["ipCode"],initialCommodityId: params["initialCommodityId"],ipName: params["ipName"]);
        case exchangeSelectTargetPage:
          return EcyExchangeSelectTargetPage();
        case systemNoticePage:
          return const EcySystemNoticePage();
        default:
          return ContainPage(key: const Key("home"), appLinks: gAppLinks);
      }
    }
  }

  Future<dynamic> push(BuildContext context, String url, dynamic params) {
    return Navigator.push(context, MaterialPageRoute(builder: (context) {
      return _getPage(url, params);
    }));
  }

  Future<dynamic> pushReplacement(
      BuildContext context, String url, dynamic params) {
    return Navigator.pushReplacement(context,
        MaterialPageRoute(builder: (context) {
          return _getPage(url, params);
        }));
  }

  EcyRouter.pushNoParams(BuildContext context, String url) {
    print("EcyRouter.pushNoParams---" + url);
    Navigator.push(context, MaterialPageRoute(builder: (context) {
      return _getPage(url, null);
    }));
  }

  EcyRouter.push(BuildContext context, String url, dynamic params) {
    print("EcyRouter.push---" + url + '-----params:' + params.toString());
    Navigator.push(context, MaterialPageRoute(builder: (context) {
      return _getPage(url, params);
    }));
  }

  EcyRouter.pushWithNeedLogin(
      BuildContext context, String url, dynamic params) {
    print("EcyRouter.push---" + url + '-----params:' + params.toString());
    EcyUserUtil.logined().then((logined) {
      if (logined) {
        Navigator.push(context, MaterialPageRoute(builder: (context) {
          return _getPage(url, params);
        }));
      } else {
        Navigator.push(context, MaterialPageRoute(builder: (context) {
          return _getPage(passwordLoginPage, params);
        }));
      }
    });
  }

  EcyRouter.popAndPushNamed(BuildContext context, String url, dynamic params) {
    Navigator.popAndPushNamed(context, url, arguments: params);
  }

  EcyRouter.pop(BuildContext context, String url) {
    print("EcyRouter.pop---" + url);
    if (url.isEmpty) {
      Navigator.pop(context);
    } else {
      Navigator.popUntil(context, (route) => route.settings.name == url);
    }
  }

  pushWithNeedLogin(
      BuildContext context, String url, dynamic params, Function onChange) {
    print("EcyRouter.push---" + url + '-----params:' + params.toString());
    EcyUserUtil.logined().then((logined) {
      if (logined) {
        Navigator.push(context, MaterialPageRoute(builder: (context) {
          return _getPage(url, params);
        })).then((val) => val ?? false ? onChange(val) : null);
      } else {
        Navigator.push(context, MaterialPageRoute(builder: (context) {
          return _getPage(passwordLoginPage, params);
        }));
      }
    });
  }

  Future<dynamic> pushWithCallBack(
      BuildContext context, String url, dynamic params, Function onCallBack) {
    return Navigator.push(context, MaterialPageRoute(builder: (context) {
      return _getPage(url, params);
    })).then((val) => val ?? false ? onCallBack(val) : null);
  }

  EcyRouter.pushReplacementNoParams(BuildContext context, String url) {
    Navigator.pushReplacement(context, MaterialPageRoute(builder: (context) {
      return _getPage(url, null);
    }));
  }

  EcyRouter.pushReplacement(BuildContext context, String url, dynamic params) {
    Navigator.pushReplacement(context, MaterialPageRoute(builder: (context) {
      return _getPage(url, params);
    }));
  }

}
